package com.yiwenup.struct._03_collect;

import com.yiwenup.struct._03_collect.map.HashMap;
import com.yiwenup.struct._03_collect.map.LinkedHashMap;
import com.yiwenup.struct._03_collect.map.TreeMap;
import com.yiwenup.struct._03_collect.map.base.Map;
import com.yiwenup.struct._03_collect.set.ListSet;
import com.yiwenup.struct._03_collect.set.TreeSet;
import com.yiwenup.struct._03_collect.set.base.Set;

public class Main {
    public static void main(String[] args) {
//        test1();
//        test2();
//        test3();
//        test4();
//        test5();

    }

    private static void test5() {
        HashMap<Object, Object> map = new LinkedHashMap<>();
        for (int i = 0; i < 10; i++) {
            map.put(i + "*key", i + "*value");
        }
        map.remove("0*key");
        map.traversal(new Map.Visitor<Object, Object>() {
            @Override
            public boolean visit(Object key, Object value) {
                System.out.println(key + "_" + value);
                return false;
            }
        });
    }

    private static void test4() {
        HashMap<Object, Object> map = new HashMap<>();
        map.put("jack", 1);
        map.put("roes", 2);
        map.put("jack", 3);
        System.out.println(map.size());
        System.out.println(map.get("jack"));
        System.out.println(map.remove("roes"));
        System.out.println(map.size());
    }

    private static void test3() {
        TreeMap<String, Integer> treeMap = new TreeMap<>();
        treeMap.put("class", 2);
        treeMap.put("public", 5);
        treeMap.put("public", 8);
        treeMap.traversal(new Map.Visitor<String, Integer>() {
            @Override
            public boolean visit(String key, Integer value) {
                System.out.println(key + "_" + value);
                return false;
            }
        });
    }

    private static void test2() {
        TreeSet<Object> treeSet = new TreeSet<>();
        treeSet.add(11);
        treeSet.add(12);
        treeSet.add(11);
        treeSet.add(10);
        treeSet.traversal(new Set.Visitor<Object>() {
            @Override
            public boolean visit(Object element) {
                System.out.println(element);
                return false;
            }
        });
    }

    private static void test1() {
        ListSet<Integer> listSet = new ListSet<>();
        listSet.add(11);
        listSet.add(12);
        listSet.add(11);
        listSet.add(10);
        listSet.traversal(new Set.Visitor<Integer>() {
            @Override
            public boolean visit(Integer element) {
                System.out.println(element);
                return false;
            }
        });
    }
}
